<?php

namespace common\models\business;

use Yii;

/**
 * This is the model class for table "business_farmer_relation".
 *
 * @property string $id
 * @property string $name
 * @property string $relation
 * @property integer $age
 * @property string $gender
 * @property string $nation
 * @property string $identity
 * @property string $birthplace
 * @property integer $farmerid
 */
class BusinessFarmerRelation extends \yii\db\ActiveRecord
{

    //主要用于日志记录
    public $uselog = [
        'tabcomment' => '农户亲属',      //用于修改了什么的显示
        'mainfield' => 'name',      //主要的显示标题的字段
        'picturefield' => [],        //图片字段
        'timefield' => [],       //时间字段
        'unsetfiled' =>[],      //不需要记录的字段
    ];



    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'business_farmer_relation';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['age', 'farmerid','relation','nation', 'identity', ], 'required'],
            [['age', 'farmerid'], 'integer'],
            [['name', 'relation', 'nation', 'identity', 'birthplace'], 'string', 'max' => 255],
            [['gender'], 'string', 'max' => 2],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '姓名',
            'relation' => '关系',
            'age' => '年龄',
            'gender' => '性别',
            'nation' => '民族',
            'identity' => '身份证',
            'birthplace' => '出生地',
            'farmerid' => '关系人',
        ];
    }


    public function getFarmer()
    {
        return $this->hasOne(BusinessFarmers::className(),['id'=>'farmerid']);

    }


}
